package ro.codetwisters.requestor;

import ro.codetwisters.requestor.json.JSONException;
import ro.codetwisters.requestor.json.JSONObject;

/**
 * Created by IntelliJ IDEA.
 * User: codetwister
 * Date: 7/1/11
 * Time: 9:17 PM
 * To change this template use File | Settings | File Templates.
 */
public class MyHttpHeader {

    private String name;
    private String value;

    public MyHttpHeader(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public MyHttpHeader(JSONObject headerJson) {
        parseJson(headerJson);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public JSONObject getJsonObj() throws JSONException {
        JSONObject obj = new JSONObject();
        obj.put("name", name);
        obj.put("value", value);
        return obj;
    }

    public void parseJson(JSONObject obj) {
        name = obj.optString("name");
        value = obj.optString("value");
    }

    @Override
    public String toString() {
        return name+" | "+value;
    }
}
